const express = require('express');
const router = module.exports = express.Router();
const testData = require("../test");
router.get('/', (req, res) => {
    let blockId = req.query.id;
    let articles = [];
    for (let i = 0; i < testData.article.length; i++) {
        const article = testData.article[i];
        if (article.blockId == blockId) {
            articles.push(article);
        }
    }
    res.render('articles', { articleData: { list: articles } });
});

router.get('/:id', (req, res) => {
    for (let i = 0; i < testData.article.length; i++) {
        const article = testData.article[i];
        if (article.articleId == req.params.id) {
            res.render('article', { article: article });
            return;
        }
    }
    res.render('404');
});